// components/common/coupon-item/index.js
import dayjs from 'dayjs';
import componentBehavior from '../../../behaviors/component';
import { COMPONENT_OPTIONS, WEEK_ZH } from'../../../constants/common';

Component({
    behaviors: [componentBehavior],
    options: {
        ...COMPONENT_OPTIONS,
    },
    properties: {
        type: {
            type: String,
            value: 'normal', // normal | select
        },
        checked: {
            type: Boolean,
            value: false,
        },
        couponInfo: {
            type: Object,
            value: null,
        }
    },
    observers: {
        'couponInfo': function(info) {
            if (info) {
                this.setData({
                    _unit: this._unit({ info }),
                    _date: this._date({ info }),
                    _price: this._price({ info }),
                    _statusT: this._statusT({ info }),
                    _voucherType: this._voucherType({ info }),
                    _voucherTypeName: this._voucherTypeName({ info }),
                });
            }
        },
    },
    data: {
    },
    methods: {
        handleClick(e) {
            const { couponInfo } = this.data;
            this.triggerEvent('click', couponInfo);
        },
    }
})